Skip to content

tests: cloud: Use strnlen() for ssafety#119

Merged
jtguggedal merged 1 commit intomainfrom
cloud-test-fixes
Mar 19, 2025
Merged

tests: cloud: Use strnlen() for ssafety#119
jtguggedal merged 1 commit intomainfrom
cloud-test-fixes

Conversation

@jtguggedal
Copy link
Copy Markdown
Contributor

Use strnlen() instead of strlen(). It was safe in this case, but always nice to use strnlen() when possible.
Flagged by Sonarcloud.

Use strnlen() instead of strlen(). It was safe in this case, but
always nice to use strnlen() when possible.
Flagged by Sonarcloud.

Signed-off-by: Jan Tore Guggedal <jantore.guggedal@nordicsemi.no>
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Core Changes: The primary change in this PR is the replacement of strlen() with strnlen() in the test file cloud_module_test.c. This change enhances safety by preventing potential buffer overflows when determining the length of strings. Additionally, a preprocessor directive is added to ensure strnlen() is available when compiling with -std=c99.

⚠️ Concerns: There are no significant concerns with this change as it improves safety without altering the logic or functionality of the tests.

Verdict: Approve. The changes are straightforward, improve safety, and are unlikely to introduce any issues.


Code review performed by OPENAI - gpt-4o.

@sonarqubecloud
Copy link
Copy Markdown

@jtguggedal jtguggedal merged commit 7e0967b into main Mar 19, 2025
4 checks passed
@jtguggedal jtguggedal deleted the cloud-test-fixes branch March 19, 2025 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant